#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    vector<vector<int>> arr(n, vector<int>(m));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> arr[i][j];

    vector<vector<long long>> dp(n + 1, vector<long long>(m + 1, 0));
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] + arr[i - 1][j - 1] - dp[i - 1][j - 1];

    int x1, y1, x2, y2;
    while (q--)
    {
        cin >> x1 >> y1 >> x2 >> y2;
        cout << dp[x2][y2] - dp[x1-1][y2] - dp[x2][y1-1] + dp[x1-1][y1-1] << endl;
    }

    return 0;
}

struct ListNode {
    int val;
    struct ListNode* next;
    ListNode(int x) : val(x), next(nullptr) {}
};

class Solution {
public:
    ListNode* addInList(ListNode* head1, ListNode* head2) {
        vector<int> num1;
        vector<int> num2;
        ListNode* cur = head1;
        while (cur)
        {
            num1.emplace_back(cur->val);
            cur = cur->next;
        }
        cur = head2;
        while (cur)
        {
            num2.emplace_back(cur->val);
            cur = cur->next;
        }
        vector<int> tmp;
        int next = 0, i1 = num1.size() - 1, i2 = num2.size() - 1;
        for (; i1 >= 0 && i2 >= 0; --i1, --i2)
        {
            int sum = num1[i1] + num2[i2] + next;
            next = sum / 10;
            sum %= 10;
            tmp.emplace_back(sum);
        }
        while (i1 >= 0)
        {
            int sum = num1[i1] + next;
            next = sum / 10;
            sum %= 10;
            tmp.emplace_back(sum);
            --i1;
        }
        while (i2 >= 0)
        {
            int sum = num2[i2] + next;
            next = sum / 10;
            sum %= 10;
            tmp.emplace_back(sum);
            --i2;
        }
        if (next)
            tmp.emplace_back(next);
        reverse(tmp.begin(), tmp.end());
        ListNode* head = new ListNode(tmp[0]);
        cur = head;
        for (int i = 1; i < tmp.size(); ++i)
        {
            ListNode* newnode = new ListNode(tmp[i]);
            cur->next = newnode;
            cur = cur->next;
        }
        return head;
    }
};

int main2()
{
    ListNode* head1 = new ListNode(9);
    head1->next = new ListNode(3);
    head1->next->next = new ListNode(7);

    ListNode* head2 = new ListNode(6);
    head2->next = new ListNode(3);

    auto ret = Solution().addInList(head1, head2);
    while (ret)
    {
        cout << ret->val << " -> ";
        ret = ret->next;
    }
    cout << endl;

    return 0;
}

class Solution1 {
public:
    string solve(string s, string t)
    {
        string ret;
        int len1 = s.size();
        int len2 = t.size();
        int next = 0, i1, i2;
        for (i1 = len1 - 1, i2 = len2 - 1; i1 >= 0 && i2 >= 0; i1--, i2--)
        {
            int sum = s[i1] + t[i2] - 2 * '0' + next;
            next = sum / 10;
            sum %= 10;
            ret += sum + '0';
        }
        while (i1 >= 0)
        {
            int sum = s[i1] - '0' + next;
            next = sum / 10;
            sum %= 10;
            ret += sum + '0';
            --i1;
        }
        while (i2 >= 0)
        {
            int sum = t[i2] - '0' + next;
            next = sum / 10;
            sum %= 10;
            ret += sum + '0';
            --i2;
        }
        if (next)
            ret += next + '0';
        reverse(ret.begin(), ret.end());

        return ret;
    }
};

int main1()
{
    cout << Solution1().solve("1", "99") << endl;

	return 0;
}